/*
    Project:        Home Power Control
    File:           HPCLogFile.h
    Author:         christian@karunamusic.at
    Date:           01.2015
    Description:    Log to file.
 */

#ifndef HPCLOGFILE_H
#define HPCLOGFILE_H

#include <fstream>
#include <QString>
#include "HPCLogDevice.h"

class HPCLogFile : public HPCLogDevice
{
    Q_OBJECT
public:
    /** \brief Constructor.
     *
     * \param lv The loglevel.
     * \param fn The file name.
     */
    HPCLogFile( TLogLevel lv, const QString& fn );
    /** \brief Constructor.
     *
     * \param lv The loglevel.
     * \param fn The file name.
     */
    HPCLogFile( const QString&, const QString& fn );
    /** \brief Destructor
     */
    virtual ~HPCLogFile();

    /** \brief Callback method for the logmessage.
     * Print given logmessage to screen (stderr).
     *
     * \param lm the logmessage
     */
    virtual void OnLog( const HPCLogMessage& lm );

private:
    std::ofstream m_Out; /**< handle of the logfile. */
};

#endif // HPCLOGFILE_H
